<?php
namespace App\models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\MessageBag;
use Validator;
/**
 * Class Base
 * @package App\models
 * @method static Model find(mixed $id, array $columns = ['*'])
 * @method static Model findOrFail(mixed $id, array $columns = ['*'])
 * @method static Model firstOrFail($columns = ['*'])
 * @method static Model findOrNew(mixed $id, array $columns = ['*'])
 * @method static Model firstOrNew(array $attributes, array $values = [])
 * @method static Model firstOrCreate(array $attributes, array $values = [])
 * @method static Model updateOrCreate(array $attributes, array $values = [])
 * @method static Model create(array $attributes = [])
 * @method static Builder where($column, $operator = null, $value = null, $boolean = 'and')
 * @method static Builder orWhere($column, $operator = null, $value = null)
 * @method static Collection findMany(array $ids, array $columns = ['*'])
 * @method static Collection get($columns = ['*'])
 * @method static Collection pluck($column, $key = null)
 * @method static \Illuminate\Contracts\Pagination\LengthAwarePaginator paginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
 * @method static \Illuminate\Contracts\Pagination\LengthAwarePaginator simplePaginate($perPage = null, $columns = ['*'], $pageName = 'page', $page = null)
 */
class Base extends Model
{
    /**
     * @var MessageBag
     */
    protected  $_validateErrors = null ;
    public function validate($data = []){
        $validate = Validator::make($data,$this->rules());
        if($validate->fails()){
            $this->_validateErrors = $validate->errors() ;
            return false ;
        }
        return true ;
    }

    public function rules(){
        return [] ;
    }

    public function getErrors(){
        return $this->_validateErrors ;
    }
}